/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.brucexx.assistx.util;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 *
 * @author zhao.xiong
 */
public class ThreadPoolUtil {

    private static final Map<String, ExecutorService> poolMap = new HashMap<String, ExecutorService>();

    public static ExecutorService getPool(String bizKey, final int coreSize) {
        ExecutorService pool = poolMap.get(bizKey);
        if (pool == null || pool.isShutdown()) {
            ExecutorService es = Executors.newFixedThreadPool(coreSize);
            poolMap.put(bizKey, es);
        }
        return poolMap.get(bizKey);
    }
}
